﻿namespace PowerSong.UserInterface.Tasks
    {
    using System;
    using PowerSong.Export;

    public class ExportTask : Task
        {

        private BaseExport exporter = null;

        public string[] Messages { get; private set; }

        public ExportTask(BaseExport exporter, string taskDescription)
            : base("Exporting Data", taskDescription)
            {
            this.exporter = exporter;
            this.exporter.ReportProgress += exporter_ReportProgress;
            }

        private void exporter_ReportProgress(int percentage, string status)
            {
            base.SetProgress(percentage, status);
            }

        public override void Execute()
            {
            this.Messages = exporter.ExportData();
            }

        public override void HandleException(Exception ex)
            {
            Utilities.ShowErrorMessage("Cannot Export Data", "The data could not be exported:", ex.Message);
            }

        }

    }
